<!--
 * @Author: g05047
 * @Date: 2020-12-25 12:00:03
 * @LastEditors: g05047
 * @LastEditTime: 2021-09-08 11:09:24
 * @Description: file content
-->
<template>
  <div v-if="total" class="fenye">
    <el-pagination
      :background="background"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-size="pageSize"
      layout="total, prev, pager, next"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
// import { scrollTo } from '@/utils/scroll-to'

export default {
  name: 'Pagination',
  props: {
    total: {
      required: true,
      type: Number,
    },
    page: {
      type: Number,
      default: 1,
    },
    pageSize: {
      type: Number,
      default: 10,
    },
    layout: {
      type: String,
      default: 'total,prev, pager, next',
    },
    background: {
      type: Boolean,
      default: true,
    },
    autoScroll: {
      type: Boolean,
      default: false,
    },
    hidden: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {
    currentPage: {
      get() {
        return this.page;
      },
      set(val) {
        this.$emit('update:page', val);
      },
    },
  },
  created() {},
  methods: {
    handleCurrentChange(val) {
      this.$emit('pagination', { page: val });
      // if (this.autoScroll) {
      //   scrollTo(0, 800)
      // }
    },
  },
};
</script>
<style lang="scss" scoped>
.fenye {
  text-align: right;
  padding-top: 20px;
  padding-right: 30px;
}
</style>
